'use strict';

import React, { PropTypes } from 'react';
import {
  View,
  requireNativeComponent,
  NativeModules,
  DeviceEventEmitter
} from 'react-native';

var BDMapManager = NativeModules.RCTBaiduMapView;

const MapView = React.createClass({

  propTypes: {

    ...View.propTypes,
     // baiduHeatMapEnabled : React.PropTypes.bool,

      baiduHeatMapEnabled: PropTypes.object,


      marker: React.PropTypes.shape({
          latitude: React.PropTypes.number.isRequired,
          longitude: React.PropTypes.number.isRequired,
          initMap: React.PropTypes.string.isRequired,
          isRefresh: React.PropTypes.string.isRequired,
     }),

     markers: React.PropTypes.arrayOf(React.PropTypes.shape({
          latitude: React.PropTypes.string.isRequired,
          longitude: React.PropTypes.string.isRequired,
          ruralId:React.PropTypes.string.isRequired,
          type:React.PropTypes.string.isRequired,
      })),

      onMapClick: React.PropTypes.func,
      onMarkerClick: React.PropTypes.func,
      onMapStatusChange:React.PropTypes.func,
      onMapStatusDidChange:React.PropTypes.func,
},



  _onChange:function(event) {
    if (typeof this.props[event.nativeEvent.type] === 'function') {
      this.props[event.nativeEvent.type](event.nativeEvent.params);
    }
  },

  render: function() {
    return (<RCTBDMap {...this.props}  markers={this.props.markers}  amarkersd={this.props.marker} onChange={this._onChange}/>);
  }
});

var RCTBDMap = requireNativeComponent('RCTBaiduMapView', MapView, {
  nativeOnly: {onChange: true}
});
module.exports = MapView;
